<template>
  <a-spin :spinning="confirmLoading" style="background: #fff">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-row :gutter="48">
          <a-col :span="8" :hidden="true">
            <a-form-model-item label="流程名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bpmBizTitle" >
              <a-input :max-length="255" disabled v-model="model.bpmBizTitle" placeholder="请输入流程名称"></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="创建日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="createTime">
              <j-date
                placeholder="请选择创建日期"
                v-model="model.createTime"
                :show-time="true"
                date-format="YYYY-MM-DD HH:mm:ss"
                style="width: 100%"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="单据编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderCode">
              <a-input v-model="model.tenderCode" placeholder="请输入单据编号" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="经办人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="handlerId">
              <select-user-by-dep
                v-model="model.handlerId"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="经办部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="handlerDeptId">
              <j-select-depart v-model="model.handlerDeptId" disabled/>
            </a-form-model-item>
          </a-col>

          <a-divider>基本信息</a-divider>
          <template v-if="model.applyType == '2'" >
            <a-col :span="8">
              <a-form-model-item label="关联投标档案" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderFinalId">
                <select-omc-project-tender-input
                  :data-isolation="'tender_person'"
                  :data-type="'emp'"
                  disabled
                  v-model="model.tenderFinalId"
                />
              </a-form-model-item>
            </a-col>
          </template>
          <a-col :span="8">
            <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="prepareProjectId">
              <a-input :readOnly="true" v-model="model.projectName" style="color: #1890FF;" @click.prevent="getProjectDetail(model.prepareProjectId)"></a-input>
            </a-form-model-item>
          </a-col>
          <!--BUG#3517-->
          <!-- <a-col :span="12">
            <a-form-model-item label="项目名称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectName">
              <a-input :disabled="formDisabled" v-model="model.projectName" placeholder="请输入项目名称" disabled></a-input>
            </a-form-model-item>
          </a-col> -->
          <!-- <a-col :span="12">
            <a-form-model-item label="项目类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectType">
              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.projectType" dictCode="xmlx_type"
                                placeholder="请选择项目类型" disabled/>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="8">
            <a-form-model-item label="项目承接人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="undertaker">
              <!--              <a-input :disabled="formDisabled" v-model="model.undertaker" placeholder="请输入承接人"  ></a-input>-->
              <select-user-by-dep
                placeholder="请选择项目承接人"
                v-model="model.undertaker"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="业绩归属年度" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="year">
              <j-dict-select-tag
                type="list"
                v-model="model.year"
                dictCode="yjgsnd"
                placeholder="请选择业绩归属年度"
                disabled/>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="12">
            <a-form-model-item label="项目地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectAddress">
              <j-area-linkage :disabled="formDisabled" type="cascader" v-model="model.projectAddress" placeholder="请输入省市区"
                              disabled/>
            </a-form-model-item>
          </a-col> -->
          <a-col :span="16">
            <a-form-model-item
              label="项目地址"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              style="height: 65px"
            >
              <a-form-model-item style="display: inline-block; width: 46%" prop="projectAddress">
                <AddressChoice disabled v-model="model.projectAddress" ></AddressChoice>
              </a-form-model-item>
              <a-form-model-item
                style="display: inline-block; width: 53%; padding-left: 1%"
                prop="detailedAddress">
                <a-input disabled v-model="model.detailedAddress" placeholder="请输入项目详细地址"></a-input>
              </a-form-model-item>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="经营团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="businessTeam">
              <!--              <a-input :disabled="formDisabled" v-model="model.businessTeam" placeholder="请输入经营团队"  ></a-input>-->
              <select-team-input
                v-model="model.businessTeam"
                :tdlx="1"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="报名截止时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="entriesEndDate">
              <j-date
                dateFormat="YYYY-MM-DD HH:mm:ss"
                :disabled="formDisabled"
                placeholder="请选择报名截止时间"
                v-model="model.entriesEndDate"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="投标截止时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderEndDate">
              <j-date
                dateFormat="YYYY-MM-DD HH:mm:ss"
                :disabled="formDisabled"
                placeholder="请选择投标截止时间"
                v-model="model.tenderEndDate"
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="业主单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ownerUnit">
              <!--              <a-input :disabled="formDisabled" v-model="model.ownerUnit" placeholder="请输入业主单位"  ></a-input>-->
              <select-customer-input
                v-model="model.ownerUnit"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="业主联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ownerLinkman">
              <!--              <a-input :disabled="formDisabled" v-model="model.ownerLinkman" placeholder="请输入业主联系人"  ></a-input>-->
              <j-dict-select-tag
                type="list"
                v-model="model.ownerLinkman"
                :dictCode="customer_contacts"
                placeholder="请选择联系人"
                :triggerChange="true"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="业主联系方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="ownerTel">
              <a-input @change="handleChange" v-model="model.ownerTel" placeholder="请输入业主联系方式" disabled></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="招标方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="biddingMethod">
              <j-dict-select-tag
                @input="handleChange"
                type="list"
                v-model="model.biddingMethod"
                dictCode="bidding_method"
                placeholder="请选择招标方式"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="招标控制价(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="controlPrice">
              <a-input :disabled="editDisabled" v-model="model.controlPrice" placeholder="请输入招标控制价" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="标书费(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="entryFee">
              <a-input :disabled="editDisabled" v-model="model.entryFee" placeholder="请输入标书费" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="投标保证金(元)" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderBond">
              <a-input :disabled="editDisabled" v-model="model.tenderBond" placeholder="请输入投标保证金" ></a-input>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="项目公示信息" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="projectPublicity">
              <a-textarea
                :max-length="500"
                v-model="model.projectPublicity"
                rows="4"
                placeholder="请输入项目公示信息"
                disabled/>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="投标内容概要" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderContent">
              <a-textarea
                v-model="model.tenderContent"
                rows="4"
                placeholder="请输入投标内容概要"
                disabled/>
            </a-form-model-item>

            <a-form-model-item label="招标文件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderFile">
              <j-upload v-if="!formDisabled" v-model="model.tenderFile" disabled></j-upload>
              <a-button v-else icon="download" @click="viewFile(model.tenderFile)">文件列表</a-button>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-divider>投标单位信息</a-divider>
        <a-row :gutter="48">
          <a-col :span="8">
            <a-form-model-item label="投标部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderDept">
              <j-select-depart disabled v-model="model.tenderDept"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="投标编制人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderPerson">
              <!--              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.tenderPerson" dictCode="" placeholder="请选择投标编制人" />-->
              <select-user-by-dep
                disabled
                :multi="false"
                v-model="model.tenderPerson" ></select-user-by-dep>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="投标单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="tenderUnit">
              <!--              <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.tenderUnit" dictCode="erp_company_files,file_name,id,del_flag = 0 and audit_status = 2" placeholder="请选择投标单位"/>-->
              <select-Company-input v-model="model.tenderUnit" />
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item label="是否需要协调" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="needHelp">
              <j-dict-select-tag
                @input="isTeamworkChange"
                type="radio"
                v-model="model.needHelp"
                dictCode="YES_OR_NO"
                placeholder="请选择是否需要协调"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="8">
            <a-form-model-item
              label="协同人员（多选）"
              v-show="model.needHelp==1"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="helperIds">
              <select-user-by-dep
                :multi="true"
                v-model="model.helperIds" ></select-user-by-dep>
            </a-form-model-item>
          </a-col>
          <a-col :span="24">
            <a-form-model-item label="备注" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="remarks">
              <a-textarea :maxLength="500" disabled v-model="model.remarks" rows="4" placeholder="备注"/>
            </a-form-model-item>
          </a-col>
          <a-divider>业务分类</a-divider>
          <!--          业务分类-->
          <a-col :span="24">
            <a-table
              ref="table"
              size="middle"
              rowKey="id"
              :loading="loading"
              :columns="columns"
              :pagination="false"
              :data-source="dataSource">
            </a-table>
          </a-col>
          <a-col :span="12">
            <a-form-model-item
              label="投标部门负责人"
              v-if="isShowOther"
              :labelCol="labelCol"
              :wrapperCol="wrapperCol"
              prop="deptLeading">
              <select-user-by-dep v-model="model.deptLeading"/>
            </a-form-model-item>
          </a-col>
          <!-- <a-col :span="24" style="text-align: center">
            <a-button   @click="submitForm">提 交</a-button>
          </a-col> -->
        </a-row>
      </a-form-model>
      <common-flow-list v-if="formBpm && model.bpmStatus !== '1'" :formData="formData" style="margin-top: 10px"></common-flow-list>
      <view-file-modal ref="viewFileModal"></view-file-modal>
      <erp-omc-tender-service-modal ref="itemList" @ok="modalFormOk"></erp-omc-tender-service-modal>
    </j-form-container>
    <a-row :gutter="48" v-if="formBpm">
      <a-col :span="24" style="text-align: center;margin-top: 15px">
        <a-button type="primary" :style="{ marginRight: '10px' }" @click="onPrint">打印</a-button>
        <a-button @click="submitForm('submit')">提 交</a-button>
      </a-col>
    </a-row>
    <!-- 项目详情开始 -->
    <erp-project-report-modal ref="reportForm"></erp-project-report-modal>
    <ErpOmcTenderEngineerFinalFormPrint v-if="formBpm && isSubmit" id="engineerfinalContent" class="print_style" :formData="model1" :formDataHistory="formData"></ErpOmcTenderEngineerFinalFormPrint>
  </a-spin>
</template>

<script>

import { getAction, httpAction } from '@/api/manage'
import { viewFile } from '@/utils/util'
import moment from 'moment'
import { mapGetters } from 'vuex'
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
import SelectTeamInput from '@/views/scy/components/SelectTeamInput'
import SelectCustomerInput from '@/views/scy/components/SelectCustomerInput'
import ViewFileModal from '@/views/scy/components/ViewFileModal'
import { filterMultiDictText, initDictOptions } from '@comp/dict/JDictSelectUtil';
import ErpOmcTenderServiceModal from '@/views/erp/omc/tender/modules/ErpOmcTenderServiceModal'
import { DisabledAuthFilterMixin } from '@/mixins/DisabledAuthFilterMixin';
import SelectProjectInput from '@/views/scy/components/SelectProjectInput';
import { putAction } from '../../../../../api/manage'
import Ellipsis from '@/components/Ellipsis'
import AddressChoice from '@/components/AddressChoice/AddressChoice';
import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
import JSelectDepart from '../../../../../components/jeecgbiz/JSelectDepart';
import CommonFlowList from '@/views/components/CommonFlowList.vue';
import ErpProjectReportModal from '@/views/erp/report/project/modules/ErpProjectReportModal';
import SelectOmcProjectTenderInput from '@/views/scy/components/SelectOmcProjectTenderInput';
import Print from '@/utils/print/printarea.js';
import ErpOmcTenderEngineerFinalFormPrint from './ErpOmcTenderEngineerFinalFormPrint' // 打印
export default {
  name: 'ErpOmcTenderForm',
  mixins: [DisabledAuthFilterMixin, viewFile],
  components: {
    SelectOmcProjectTenderInput,
    ErpProjectReportModal,
    JSelectDepart,
    SelectCompanyInput,
    Ellipsis,
    ViewFileModal,
    SelectUserByDep,
    SelectTeamInput,
    SelectCustomerInput,
    SelectProjectInput,
    ErpOmcTenderServiceModal,
    AddressChoice,
    CommonFlowList,
    ErpOmcTenderEngineerFinalFormPrint
  },
  props: {
    // 流程表单data
    formData: {
      type: Object,
      default: () => {
      },
      required: false
    },
    // 表单模式：true流程表单 false普通表单
    formBpm: {
      type: Boolean,
      default: false,
      required: false
    },
    // 表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      isSubmit: true,
      engineerStatus: {
        type: Boolean,
        default: true,
        required: false
      },
      personStatus: {
        type: Boolean,
        default: true,
        required: false
      },
      finalStatus: {
        type: Boolean,
        default: false,
        required: false
      },
      loading: false,
      // unitLoading: false,
      isShowOther: false,
      columns: [
        {
          title: '业务分类',
          align: 'center',
          dataIndex: 'serviceType',
          customRender: (text) => {
            if (!text) {
              return ''
            } else {
              return filterMultiDictText(this.dictOptions['serviceType'], text + '')
            }
          }
        },
        {
          title: '业务名称',
          align: 'center',
          dataIndex: 'serviceName'
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: {
            filterDropdown: 'filterDropdown',
            filterIcon: 'filterIcon',
            customRender: 'action'
          }
        }
      ],
      dataSource: [],
      isShowTeamwork: false,
      model: {
        handlerName: ''
      },
      model1: { // 打印
        handlerName: ''
      },
      labelCol: {},
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 24 }
      },
      dictOptions: {},
      confirmLoading: false,
      validatorRules: {
        bpmBizTitle: [
          { required: true, message: '请输入流程名称!' }
        ],
        // tenderCode: [
        //    { required: false},
        //    { validator: (rule, value, callback) => validateDuplicateValue('erp_omc_tender', 'tender_code', value, this.model.id, callback)},
        // ],
        prepareProjectId: [
          { required: true, message: '请输入选择预立项项目!' }
        ],
        undertaker: [
          { required: true, message: '请输入承接人!' }
        ],
        tenderUnit: [
          { required: true, message: '请输入投标单位!' }
        ],
        year: [
          { required: true, message: '请输入业绩归属年度!' }
        ],
        projectAddress: [
          { required: true, message: '请输入项目地址!' }
        ],
        businessTeam: [
          { required: true, message: '请输入经营团队!' }
        ],
        entriesEndDate: [
          { required: true, message: '请输入报名截止日期!' }
        ],
        tenderEndDate: [
          { required: true, message: '请输入投标截止日期!' }
        ],
        ownerUnit: [
          { required: true, message: '请输入业主单位!' }
        ],
        ownerLinkman: [
          { required: true, message: '请输入业主联系人!' }
        ],
        ownerTel: [
          { required: true, message: '请输入业主联系方式!' }
        ],
        biddingMethod: [
          { required: false, message: '请输入招标方式!' }
        ],
        controlPrice: [
          { required: true, message: '请输入招标控制价!' },
          { pattern: /^([0]|([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' }
        ],
        entryFee: [
          { required: true, message: '请输入标书费!' },
          { pattern: /^([0]|([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' }
        ],
        tenderBond: [
          { required: true, message: '请输入投标保证金!' },
          { pattern: /^([0]|([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!' }
        ],
        // tenderType: [
        //   { required: true, message: '请输入投标类别!' },
        // ],
        // baseScore: [
        //   { required: true, message: '请输入基准分值!' },
        //   { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!' },
        // ],
        deptLeading: [
          { required: true, message: '请选择投标部门负责人' }
        ]
      },
      url: {
        queryProjectReportById: '/api/erp/project/report/erpProjectReport/queryById',
        add: '/api/erp/omc/tender/erpOmcTender/add',
        edit: '/api/erp/omc/tender/erpOmcTender/edit',
        queryById: '/api/erp/omc/tender/erpOmcTender/queryById',
        queryPrepareProjectById: '/api/erp/omc/prepareproject/erpOmcPrepareProject/queryById',
        queryTenderServiceListByTenderId: '/api/erp/omc/tender/erpOmcTenderService/queryTenderServiceListByTenderId'
      },
      customer_contacts: 'erp_omc_customer_manager_contact,lxr,id,del_flag=0',
      entriesEndDate: undefined,
      tenderEndDate: undefined
    }
  },
  computed: {
    formDisabled() {
      if (this.formBpm === true) {
        if (this.formData.disabled === false) {
          return false
        }
        return true
      }
      return this.disabled
    },
    // 审批时需要修改的字段
    editDisabled() {
      return false
    },
    showFlowSubmitButton() {
      if (this.formBpm === true) {
        if (this.formData.disabled === false) {
          return true
        }
      }
      return false
    }
  },
  created() {
    // 备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model));
    // 如果是流程中表单，则需要加载流程表单data
    this.showFlowData();
    this.initDictConfig();
  },
  mounted() {
    if (this.formData) {
      this.isShowOther = this.formData.isShowOther
    }
  },
  methods: {
    getProjectDetail(id) {
      const that = this
      this.$nextTick(() => {
        getAction(this.url.queryProjectReportById, { id }).then((res) => {
          if (res.success) {
            const model = res.result
            that.$refs.reportForm.getDetail(model);
            that.$refs.reportForm.title = '项目一览表';
          }
        })
      })
    },
    // 将id列表显示为姓名列表
    helperIdsRender(text) {
      let ids = text.split(',')
      if (!text || !ids || ids.length == 0) {
        return ''
      } else {
        let names = ',';
        ids.forEach(id => {
          names += filterMultiDictText(this.dictOptions['tenderPerson'], id + '') + ',';
        })
        // 去除首尾逗号
        names = names.substring(1, names.length - 1)
        if (names.length > 15) {
          names = names.substring(1, 16) + '...'
        }
        return names;
      }
    },
    // 修改时修改数据库
    handleChange() {
      if (this.model != null) {
        putAction(this.url.edit, this.model).then(res => {
          console.log(res.result)
        })
      }
    },
    initDictConfig() {
      initDictOptions('ywfx_type').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'serviceType', res.result)
        }
      })
      initDictOptions('erp_employee_file,name,id').then((res) => {
        if (res.success) {
          this.$set(this.dictOptions, 'tenderPerson', res.result)
        }
      })
    },

    modalFormOk(data) {
      this.loading = true;
      let flag = true;
      // debugger;
      for (let i = 0; i < this.dataSource.length; i++) {
        if (this.dataSource[i].id == data.id) {
          this.dataSource.splice(i, 1, data);
          flag = false;
        }
      }
      if (flag) {
        this.dataSource.push(data);
      }
      this.loading = false;
    },
    // 是否协同
    isTeamworkChange(e) {
      if (e == '1') {
        this.isShowTeamwork = true
      } else {
        this.isShowTeamwork = false
        this.model.helperIds = ''
      }
    },
    ...mapGetters(['userInfo']),
    add(value) {
      this.dataSource = []
      this.edit(this.modelDefault);
      // this.model.tenderCode = value.tenderCode;
      // this.model.handlerId = value.loginUser.empId;
      // this.model.handlerName=value.loginUser.realname;
      this.model.handlerDeptId = this.userInfo().deptId;
      this.model.isTeamwork = 0;
      this.model.createTime = moment().format('YYYY-MM-DD HH:mm:ss');
    },
    edit(record) {
      this.$nextTick(() => {
        this.$refs.form.resetFields();
      })
      this.entriesEndDate = this.model.entriesEndDate;
      this.tenderEndDate = this.model.tenderEndDate;
      this.model = Object.assign({}, record);
      this.model1 = Object.assign({}, record);
      if (this.model.id) {
        if (this.model.needHelp === '1') {
          this.isTeamworkChange('1')
        }
        getAction(this.url.queryTenderServiceListByTenderId, { id: this.model.id }).then((res) => {
          if (res.success) {
            this.dataSource = res.result.records || res.result
          }
        })
      }
      this.columns.pop()
      this.visible = true;
    },
    // 渲染流程表单数据
    showFlowData() {
      if (this.formBpm === true) {
        let params = { id: this.formData.dataId };
        getAction(this.url.queryById, params).then((res) => {
          if (res.success) {
            this.edit(res.result);
          }
        });
      }
    },
    submitForm() {
      const that = this;
      this.isSubmit = false
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          this.model.itemList = this.dataSource;
          httpAction(httpurl, this.model, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
              let params = { id: this.formData.dataId };
              getAction(this.url.queryById, params).then((res) => {
                if (res.success) {
                  this.model1 = res.result
                  this.isSubmit = true
                }
              });
            } else {
              that.$emit('unButtonDisable');
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.$emit('unButtonDisable');
            that.confirmLoading = false;
          })
        } else {
          that.$emit('unButtonDisable');
        }
      })
    },
    disabledEntriesEndDate(currentDate) {
      return currentDate < moment(this.model.createTime).subtract('day')
    },
    disabledTenderEndDate(currentDate) {
      return currentDate < moment(this.model.entriesEndDate).subtract('day')
    },
    synSubmitForm() {
      return new Promise((resolve, reject) => {
        const that = this;
        // 触发表单验证
        this.$refs.form.validate(valid => {
          if (valid) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if (!this.model.id) {
              httpurl += this.url.add;
              method = 'post';
            } else {
              httpurl += this.url.edit;
              method = 'put';
            }
            this.model.itemList = this.dataSource;
            httpAction(httpurl, this.model, method).then((res) => {
              if (res.success) {
                that.$emit('ok');
                resolve()
              } else {
                that.$message.warning(res.message);
                reject()
              }
            }).finally(() => {
              that.confirmLoading = false;
            })
          }
        })
      })
    },

    // 点击打印
    onPrint () {
      let print = new Print({
        el: '#engineerfinalContent',
        popTitle: '投标详情 · 禾美环保',
        endCallback() {

        }
      })
    }
  }
}
</script>
<style scoped>
.ant-divider {
  font-size: 10px;
  font-weight: bold;
}

/*.ant-tabs{
  width: 850px;
}*/
</style>
<style>
  @import "../../../../../utils/print.css";
</style>
